package commands;

import utils.CommandStack;
import utils.EditorContext;

public class RedoCommand extends Command {

    public RedoCommand(EditorContext context) {
        super(context);
    }

    @Override
    public void execute() {
        context.setSavingState(EditorContext.SavingState.ToSave);
        if (CommandStack.getRedoCommand() == null) {
            throw new IllegalStateException("There is no command to redo.");
        } else {
            context.setContent(CommandStack.getRedoCommand().getContext().getContent());
            CommandStack.getInstance().add(CommandStack.getRedoCommand());
            CommandStack.setRedoCommand(null);
        }
    }

}
